package com.lwj.liwanjia.model;

import com.lwj.liwanjia.api.ApiService;
import com.lwj.liwanjia.bean.fabu.FabuTbBean;
import com.lwj.liwanjia.utils.RetrofitHelper;

import java.io.File;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/1/14.
 */

public class FbTbUploadModel {
    public void uploadTb(File file, String token, Subscriber<FabuTbBean> subscriber) {
        RequestBody body = RequestBody.create(MediaType.parse("application/otcet-stream"), file);
        MultipartBody.Part part = MultipartBody.Part.createFormData("aFile", file.getName(), body);
        RetrofitHelper.getSingleRetrofit()
                .create(ApiService.class)
                .uploadTb(part, token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }
}
